//Name: Sara Thorup
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
void test();
/*
WARNING! INCLUDE IN DOMINION.H int playSmithy(int handPos, int currentPlayer, struct gameState *state, int trashFlag)
Unit tests for int playSmithy(int handPos, int currentPlayer, struct gameState *state, int trashFlag)
playSmithy() allows the player to draw three additional cards and puts them in their hand

Things to test:
- hand count is incremented by three
- three new cards are in hand
*/

int main(int argc, char *argv[]) {
	printf("\n ===== Testing Smithy card =====\n");
	test();
	return 0;
}

void test() {
	//setup
	struct gameState* gameState = newGame();
	int testPlayer = 0;
	int numPlayers = 2;
	int kingdomCards[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
	int randomSeed = 10;
	if (initializeGame(numPlayers, kingdomCards, randomSeed, gameState) != 0){
		printf("Error initalizing game. \n");
		return;
	}
	int cardsGained = 3;
	
	int initalHandCount = gameState->handCount[testPlayer];
	int initalDeckCount = 15;  //set default deck count
	int initalDiscardCount = 15; //set discard count

	//fill deck and discard with gold cards
	gameState->deckCount[testPlayer] = initalDeckCount;
	int i = 0;
	for (; i < initalDeckCount; i++) {
		gameState->deck[testPlayer][i] = gold;
	}
	gameState->discardCount[testPlayer] = initalDiscardCount;

	for (i = 0; i < initalDiscardCount; i++) {
		gameState->discard[testPlayer][i] = gold;
	}

	for (i = 0; i < initalHandCount; i++ ){
		gameState->hand[testPlayer][i] = smithy;
	}


	//put smithy in hand
	int handPos = 3;
	initalHandCount--; //subtract a card since the smithy will be discarded
	
	playSmithy(handPos, testPlayer, gameState, 0);

	int newHandCount = gameState->handCount[testPlayer];

	if (newHandCount == initalHandCount + cardsGained) {
		printf("Smithy Card: PASS number of cards in hand incremented  \n"  );
	} else {
		printf("Smithy Card: FAIL number of cards in hand  not incremented \n");
	}

	if (gameState->hand[testPlayer][newHandCount - 1] && gameState->hand[testPlayer][newHandCount - 2] && gameState->hand[testPlayer][handPos] == gold){
		printf("Smithy Card: PASS three new cards were added  \n"  );
	} else {
		printf("Smithy Card: FAIL three new cards were not added  \n"  );
		
	}
}